<?php 
/**
 * 收货地址管理模型
 */
class AddressModel extends Model{
    public $table = 'address';
    
    public $auto = array(
//		array('uid','_uid','method',2,1),
//		array('area','_area','method',2,3),
	);
	/**
	 * 所属用户id
	 */
//	public function _uid(){
//		return session('uid');
//	}
	/**
	 * 组合所属地区
	 */
    public function _area(){
    	return Q('post.province').",".Q('post.city').",".Q('post.county');
    }
    public $validate = array(
		array('aname','nonull','收货人不能为空',2,3),
		array('aname','china','收货人必须为汉字',2,3),
		array('amobile','nonull','联系方式不能为空',2,3),
		array('amobile','amobile:6,13','联系方式格式不正确',2,3),
		array('address','nonull','详细地址不能为空',2,3),
		array('postalcode','maxlen:6','邮政编码不能超过6个字符',2,3),
	);
	/**
	 * 地址添加
	 */
    public function addAddress(){
    	if(!$this->create())  return false;
		$this->data['uid']=session('uid');
		$this->data['area']=Q('post.province').",".Q('post.city').",".Q('post.county');
		return $this->add();
    }
    /**
	 * 地址编辑
	 */
	public function editAddress(){
		if(!$this->create())  return false;
		$this->update();
		return true;
	}
 }
 
 
 
 
 
 
 
 
 
 
 






 ?>